﻿@model Webdiyer.WebControls.Mvc.PagedList<Sahit.iSoilHotel.Portal.ServiceProxy.Tavern.Models.Record.RecordListModel>
@{
    Sahit.iSoilHotel.Portal.ServiceProxy.Tavern.Models.Filter.RecordFilterModel filter = ViewBag.Filter;
}
<script type="text/javascript">
    $(document).ready(function () {
        bindCheckAll();
    });

    function bindCheckAll() {
        $("#selectAll").bind("click", function () {
            if (this.checked) {
                selectAllRecords();
            }
            else {
                unSelectAllRecords();
            }
        });
    }
    function selectAllRecords() {
        $("[name=record]:checkbox").attr("checked", true);
    }

    function unSelectAllRecords() {
        $("[name=record]:checkbox").attr("checked", false);
    }
</script>
<table id="recordTable" style="width: 100%;" class="sexy-table">
    <thead>
        <tr>
            <th>
                <input id="selectAll" type="checkbox" />
            </th>
            <th>
                Status
            </th>
            <th>
                Start Date
            </th>
            <th>
                End Date
            </th>
            <th>
                Room Type
            </th>
            <th>
                Room Number
            </th>
            <th>
                Customer Name
            </th>
        </tr>
    </thead>
    <tbody>
        @foreach (var item in Model)
        {
            <tr id="@item.ID">
                <td>
                    <input type="checkbox" name="record" />
                </td>
                <td class="@item.GetRecordClassByStatus()">
                    @item.Status
                </td>
                <td>@item.StartDate.ToShortDateString()
                </td>
                <td>@item.EndDate.ToShortDateString()
                </td>
                <td>@item.Room.RoomType.Name
                </td>
                <td>
                    @item.Room.Number
                </td>
                <td>
                    @item.MainCustomer.Name
                </td>
            </tr>
        }
    </tbody>
</table>
@{
    if (filter == null)
    {
    @Ajax.Pager(Model, new PagerOptions { PageIndexParameterName = "index", ShowDisabledPagerItems = true, SeparatorHtml = "&nbsp;&nbsp;&nbsp;" }, new AjaxOptions { UpdateTargetId = "divRecords" });
    }
    else
    {
    @Ajax.Pager(Model, null, new { recordStatusIDs = String.Join("~", filter.RecordStatusIDs), roomTypeID = filter.RoomTypeID, roomNumber = filter.RoomNumber }, new PagerOptions { PageIndexParameterName = "index", ShowDisabledPagerItems = true, SeparatorHtml = "&nbsp;&nbsp;&nbsp;" }, new AjaxOptions { UpdateTargetId = "divRecords" }, null);
    }
}
